package com.genius.workflow.util;

import java.text.SimpleDateFormat;
import java.util.Date;

public class TimeDiff {
	private static SimpleDateFormat sdf;
	
	
	private static int Rmills = 1000;
	private static int Rminute = 60*Rmills;
	private static int Rhours = Rminute*60;
	private static int Rdays = Rhours*24;
	public static String getTimeDiff(long mills){
		String result = "";
		long days = mills / Rdays;
		long hours = (mills % Rdays) / Rhours;
		long minutes = (mills % Rdays % Rhours) / Rminute;
		long seconds = (mills % Rdays % Rhours % Rminute) / Rmills;
		if(mills<Rminute){
			result = seconds + "秒";
		}
		else if(mills>=Rminute &&mills <Rhours){
			result = minutes + "分" + seconds + "秒";
		}else if(mills>=Rhours &&mills <Rdays){
			result = days + "天" + hours + "时" + minutes + "分" + seconds + "秒";
		}
		
	    return result;
	}
	public static String getTime(String pattern,Date date){
		sdf = new SimpleDateFormat(pattern);
		return sdf.format(date);
	}
	public static String getNowTime(String pattern){
		sdf = new SimpleDateFormat(pattern);
		return sdf.format(System.currentTimeMillis());
	}
	public static void main(String[] args) {
		//System.out.println(getTimeDiff(121122));
		System.out.println(getNowTime(Pattern.yyyyMMddHHmmss));
		
	}
}
